#!/usr/bin/python

# filename  back.py

import os
import time


source = ['/home/mysql/data','/home/www/player']
target_dir = '/home/back/';

today = target_dir + time.strftime('%Y%m%d');

now = time.strftime('%H%M%S');
#target = target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip'

if not os.path.exists(today):
	os.mkdir(today)
	print 'Successful';

#target = today+os.sep+now+'.zip'
target = today+os.sep+now+'.tar.gz'

#zip_command = "zip -qr '%s' %s" % (target,' '.join(source));
zip_command = "tar -cvzf %s %s" % (target, ' '.join(source))
print zip_command
#print zip_command
if os.system(zip_command) == 0:
	print 'success',target
else:
	print 'failed';



